package com.parttime.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.parttime.beans.Merchant_Users;
import com.parttime.beans.Personal_Users;
import com.parttime.dao.MerchantUsersDao;
import com.parttime.service.MerchantUsersManager;
@Service
public class MerchantUsersManagerImpl implements MerchantUsersManager{
	
	@Autowired
	private MerchantUsersDao merchantUsersDao;
	@Override
	public void register(Merchant_Users user) {
		// TODO Auto-generated method stub
		merchantUsersDao.register(user);
	}
	@Override
	public String validateEmail(String phone, String email) {
		// TODO Auto-generated method stub
		if(merchantUsersDao.exitsUserByAccount(phone)){
			String Email=merchantUsersDao.getEmailByPhone(phone);
			if(email.equals(Email))return null;
			else return "邮箱填写出错";
		}
		
		return "账号不存在";
	}
	@Override
	public boolean resetPassword(String phone, String password) {
		// TODO Auto-generated method stub
		Merchant_Users user=merchantUsersDao.getUserByPhone(phone);
		user.setM_password(password);
		try{
			if(merchantUsersDao.saveUser(user)){
			return true;
		}}catch(Exception e){
			return false;
		}
		return false;
	}

}
